package com.htfyun.ft.showinfo;

import android.content.Context;

import com.htfyun.ft.FTApplication;
import com.htfyun.ft.R;
import com.htfyun.ft.config.NVRomKeysAttr;
import com.htfyun.ft.device.DeviceAttr;
import com.htfyun.hardware.NVRomController;

public enum  ShowInfoItemEnum {

    bsn(NVRomKeysAttr.bsn, R.string.info_item_bsn, R.string.info_bsn_is_null),
    servo(NVRomKeysAttr.servo, R.string.ft_item_servo, R.string.servo_not_exist),
    ft_test(NVRomKeysAttr.info_ft_test, R.string.main_btn_test_factory, -1),
    sn(NVRomKeysAttr.sn, R.string.info_item_sn,  R.string.info_unburn),
    wmac(NVRomKeysAttr.wmac, R.string.info_item_wmac,  R.string.info_unburn),
    btmac(NVRomKeysAttr.btmac, R.string.info_item_btmac,  R.string.info_unburn),
    imei(NVRomKeysAttr.imei, R.string.info_item_imei,  R.string.info_unburn),
    user(NVRomKeysAttr.user, R.string.info_item_user,  R.string.info_unburn),

    pc_checked(NVRomKeysAttr.pc_checked, R.string.info_item_pc_checked, -1),
    pcba_result(NVRomKeysAttr.pcba_result, R.string.info_item_pcba_result,  R.string.info_pcba_result_is_null),

    battery(NVRomKeysAttr.battery, R.string.ft_item_battery, -1),

    ;
    private final NVRomKeysAttr nvromKey;
    private final int nameResId;
    private final int defaultInfoResId;


    private ShowInfoItemEnum(NVRomKeysAttr key, int nameResId, int defaultInfoResId) {

        this.nvromKey = key;
        this.nameResId = nameResId;
        this.defaultInfoResId = defaultInfoResId;
    }

    public boolean isShow() {
        if (getNVRomKey() == null) {
            return true;
        }
        return (DeviceAttr.isNVRomKeySupported(getNVRomKey()));
    }

    private NVRomKeysAttr getNVRomKey() {
        return nvromKey;
    }

    public String getStringFroNVRom() {
        if (getNVRomKey() == null) {
            return "";
        }
        String value = NVRomController.getInstance().getNVRomString(getNVRomKey().getKey());
        if (value == null) {
            value = "";
        }
        return value;
    }

    private int getNameResId() {
        return nameResId;
    }
    public String getName() {

        if (getNameResId() < 0) {
            return "";
        }
        try {
            final Context context = FTApplication.getContext();
            return context.getString(getNameResId());
        } catch (Exception e) {

        }
        return "";
    }

    public String getDefaultInfo() {
        if (defaultInfoResId < 0) {
            return "";
        }
        try {
            final Context context = FTApplication.getContext();
            return context.getString(defaultInfoResId);
        } catch (Exception e) {

        }
        return "";
    }
}
